﻿using System.Collections.Generic;
using System.Linq;

namespace Pap.Data
{
    /// <summary>
    /// 
    /// </summary>
    public partial class Project : IProject
    {

        #region IProject Members

        /// <summary>
        /// Gets or sets the parent project.
        /// </summary>
        /// <value>
        /// The parent project.
        /// </value>
        public IProject ParentProject
        {
            get
            {
                return Project1 as IProject;
            }
            set
            {
                Project1 = value as Project;
            }
        }

        /// <summary>
        /// Gets the stages.
        /// </summary>
        public IEnumerable<IProjectStage> Stages
        {

            get
            {
                return ProjectStages.OfType<IProjectStage>().OrderBy(stage => stage.Stage);
            }
        }

        IEnumerable<IUsersProject>  IProject.UsersProject
        {
            get
            {
                return this.UsersProjects.OfType<IUsersProject>();
            }
        }

        /// <summary>
        /// Adds the stage.
        /// </summary>
        /// <param name="stage">The stage.</param>
        public void AddStage(IProjectStage stage)
        {
            ProjectStages.Add(stage as ProjectStage);
        }

        /// <summary>
        /// Gets the committee bank accounts.
        /// </summary>
        IEnumerable<ICommitteeBankAccount> IProject.CommitteeBankAccounts
        {
            get { return this.CommitteeBankAccounts.OfType<ICommitteeBankAccount>(); }
        }

        #endregion
    }
}
